﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WinApp
{
    public partial class Form1 : Form
    {
        TSCC.Interface.iUser usr = null;

        public Form1(string p_txt)
        {
            InitializeComponent();
            this.Text = p_txt;
          }

        private void button1_Click(object sender, EventArgs e)
        {
            //TSCC.Service.Service_Exception obj = new TSCC.Service.Service_Exception();
            //DataTable dt = obj.GetExceptionDT();
            //MessageBox.Show(dt.Rows.Count.ToString());
            usr = TSCC.Service.Utility.Login("23456", string.Empty);
            MessageBox.Show(usr.GetEmployeeNo());
        }

        private void button2_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbConnection cnn = new System.Data.OleDb.OleDbConnection();
            //cnn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\VS2010B2\TSCCApp\bin\Data\EL.mdb;Password=TSCC;";
            cnn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\VS2010B2\TSCCApp\bin\Data\EL.mdb;Persist Security Info=True;Jet OLEDB:Database Password=TSCC";
            //cnn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\MY\WORK\CIB\企金.mdb;User Id=admin;Password=;";
            cnn.Open();
            IDbCommand cmd = cnn.CreateCommand();
            //System.Data.OleDb.OleDbCommand cmd = cnn.CreateCommand();
            //cmd.CommandText = "SELECT * FROM [Exception]";
            IDbDataParameter para1 = cmd.CreateParameter();
            para1.DbType = DbType.String;
            para1.Value = "23456";
            para1.ParameterName = string.Empty;

            IDbDataParameter para2 = cmd.CreateParameter();
            para2.DbType = DbType.String;
            para2.Value = "123456";
            para2.ParameterName = string.Empty;
            cmd.Parameters.Add(para1);
            cmd.Parameters.Add(para2);


            cmd.CommandText = @"SELECT Manager.PW, CSREmployee.姓名, CSREmployee.組別, CSREmployee.員編
                                    FROM CSREmployee LEFT JOIN Manager ON CSREmployee.員編 = Manager.員編
                                    WHERE CSREmployee.員編 in( ?,?) ;";
           
            System.Data.OleDb.OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) as System.Data.OleDb.OleDbDataReader;
            DataTable dt = new DataTable();
            dt.Load(dr);
            MessageBox.Show(dt.Rows.Count.ToString());
        }

        private void Form1_Deactivate(object sender, EventArgs e)
        {
            //Program.usr = usr;
        }

    }
}
